import axios from "axios";

const server = axios.create({
  baseURL: "/api",
  timeout: 60 * 1000,
});

export function request({ url = "", method = "get", data = {}, params = {} }) {
  return new Promise<void>((resolve, reject) => {
    server({ url, method, data, params })
      .then((res) => {
        let result = res.data;
        if (result.code === 200) {
          resolve(result);
        } else {
          reject(result);
        }
      })
      .catch((err) => {
        reject(err);
      });
  });
}
export default server;
